package org.cem.frontend;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.DateTime;

public class FirstWizardPage extends WizardPage {
	
	private Text txtOtherSchool;
	private Text txtKlasse;
	private Text txtStreet;
	private Text txtHausnummer;
	private Text txtPlz;
	private Text txtOrt;
	private DateTime dtBirthday;
	private Button btnSonstigeSchule;
	private Button btnTMG;
	private Text txtTelefonnummer;

	
	
	protected FirstWizardPage(String pageName) {
		super(pageName);
	}

	@Override
	public void createControl(Composite parent) {
		Composite mainComposite = new Composite(parent, SWT.NONE);
		setControl(mainComposite);
		mainComposite.setLayout(new GridLayout(2, false));
		
		Label lblName = new Label(mainComposite, SWT.NONE);
		lblName.setText("Name:");
		
		Label lblInsertName = new Label(mainComposite, SWT.NONE);
		
		Label lblVorname = new Label(mainComposite, SWT.NONE);
		lblVorname.setText("Vorname:");
		
		Label lblInsertPrename = new Label(mainComposite, SWT.NONE);
		lblInsertPrename.setText("");
		
		Label lblGeburtsdatum = new Label(mainComposite, SWT.NONE);
		lblGeburtsdatum.setText("Geburtsdatum:");
		
		dtBirthday = new DateTime(mainComposite, SWT.BORDER | SWT.DROP_DOWN);
		
		Label lblStrasse = new Label(mainComposite, SWT.NONE);
		lblStrasse.setText("Straße:");
		
		txtStreet = new Text(mainComposite, SWT.BORDER);
		GridData gd_txtStreet = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
		gd_txtStreet.widthHint = 265;
		txtStreet.setLayoutData(gd_txtStreet);
		
		Label lblHausnummer = new Label(mainComposite, SWT.NONE);
		lblHausnummer.setText("Hausnummer:");
		
		txtHausnummer = new Text(mainComposite, SWT.BORDER);
		GridData gd_txtHausnummer = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
		gd_txtHausnummer.widthHint = 31;
		txtHausnummer.setLayoutData(gd_txtHausnummer);
		
		Label lblPostleitzahl = new Label(mainComposite, SWT.NONE);
		lblPostleitzahl.setText("Postleitzahl:");
		
		txtPlz = new Text(mainComposite, SWT.BORDER);
		txtPlz.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
		
		Label lblOrt = new Label(mainComposite, SWT.NONE);
		lblOrt.setText("Ort:");
		
		txtOrt = new Text(mainComposite, SWT.BORDER);
		GridData gd_txtOrt = new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1);
		gd_txtOrt.widthHint = 134;
		txtOrt.setLayoutData(gd_txtOrt);
		
		Label lblTelefonnummer = new Label(mainComposite, SWT.NONE);
		lblTelefonnummer.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblTelefonnummer.setText("Telefonnummer:");
		
		txtTelefonnummer = new Text(mainComposite, SWT.BORDER);
		GridData gd_txtTelefonnummer = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
		gd_txtTelefonnummer.widthHint = 158;
		txtTelefonnummer.setLayoutData(gd_txtTelefonnummer);
		
		Label lblAktuelleSchule = new Label(mainComposite, SWT.NONE);
		lblAktuelleSchule.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
		lblAktuelleSchule.setText("Aktuelle Schule:");
		
		Composite schoolComposite = new Composite(mainComposite, SWT.NONE);
		schoolComposite.setLayout(new GridLayout(2, false));
		
		btnTMG = new Button(schoolComposite, SWT.RADIO);
		btnTMG.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
		btnTMG.setBounds(0, 0, 90, 16);
		btnTMG.setText("Thomas-Morus-Gymnasium Daun");
		btnTMG.setSelection(true);
		
		btnTMG.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				 txtOtherSchool.setEnabled(false);
				 txtOtherSchool.setText("");
				
			}
			
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
		
		btnSonstigeSchule = new Button(schoolComposite, SWT.RADIO);
		btnSonstigeSchule.setBounds(0, 0, 90, 16);
		btnSonstigeSchule.setText("Sonstige Schule:");
		
		btnSonstigeSchule.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				 txtOtherSchool.setEnabled(true);
				
			}
			
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
		
		txtOtherSchool = new Text(schoolComposite, SWT.BORDER);
		GridData gd_txtOtherSchool = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
		gd_txtOtherSchool.minimumWidth = 300;
		txtOtherSchool.setLayoutData(gd_txtOtherSchool);
		txtOtherSchool.setEnabled(false);
		
		Label lblKlasse = new Label(mainComposite, SWT.NONE);
		lblKlasse.setText("Klasse:");
		
		Composite compositeKlasse = new Composite(mainComposite, SWT.NONE);
		compositeKlasse.setLayout(new GridLayout(3, false));
		compositeKlasse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		
		Label lblGibDenNamen = new Label(compositeKlasse, SWT.NONE);
		lblGibDenNamen.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblGibDenNamen.setText("Gib den Namen deiner aktuellen Klasse ein (10a, 10b, ...):");
		
		txtKlasse = new Text(compositeKlasse, SWT.BORDER);
		GridData gd_txtKlasse = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
		gd_txtKlasse.widthHint = 33;
		txtKlasse.setLayoutData(gd_txtKlasse);
		new Label(compositeKlasse, SWT.NONE);
	}
}
